import 'package:mall/utils/broadcast/broadcast_util.dart';
import 'package:mall/utils/sc/state_controller.dart';

import '../model/coupon_entity.dart';
import '../service/mine_service.dart';

class CouponListSc extends PagingListSC<CouponList> implements CouponEvent{

  @override
  void onInit() {
    super.onInit();
    BroadcastUtil.register<CouponEvent>(this);
  }

  @override
  Future<List<CouponList>> loadData() async{
    final res = await MineService.queryCoupon(page, limit);
    count = res.total;
    return res.xList ?? [];
  }
  
  @override
  void receiveCoupon(int couponId) {
    refreshData();
  }
}